package ch06.action;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;


public class UserAction extends BaseAction{
    /**
     * 新增方法
     * @param request
     * @param response
     */
    public void add(HttpServletRequest request, HttpServletResponse response){
        System.out.println("---->user.add");
    }

    /**
     * 删除方法
     * @param response
     * @param request
     */
    public void det(HttpServletResponse response,HttpServletRequest request){
        System.out.println("---->user.det");
    }

    /**
     * 修改方法
     * @param request
     * @param response
     */
    public void update(HttpServletRequest request,HttpServletResponse response){
        System.out.println("---->user.update");
    }

    /**
     * 查找方法
     * @param response
     * @param request
     */
    public void query(HttpServletResponse response,HttpServletRequest request) throws IOException {
        System.out.println(request.getParameter("methodName"));
        System.out.println("---->user.query");

        List<String> userList=new ArrayList<>();
        userList.add("111");
        userList.add("222");
        userList.add("333");

        PrintWriter out=response.getWriter();

        out.print(JSON.toJSONString(userList));
        out.flush();
        out.close();
    }
}
